home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
utils
/
dtr.arc
/
dtr.c
next >
Wrap
C/C++ Source or Header
|
1987-01-18
|
3KB
|
100 lines
/*
DTR control program. Called from Shell or Desktop. Rename to DTR.PRG
if placed in AUTO folder.
Call:
DTR {"on"|"off"}
Assumes "off" if no argument.
Written by Bruce D. Nelson 1/18/87 Megamax C.
*/
#include <osbind.h>
#include <string.h>
extern giaccess();
extern rdbt();
extern dtron();
extern dtroff();
extern setbt();
extern clrbt();
asm{
giaccess:
move.w SR,-(A7) /* save status */
ori.w #0x700,SR /* IPL 7, disable ints */
movem.l D1-D2/A0,-(A7) /* Save regs */
lea 0xFFFF8800,A0 /* Adr of Sound Chip */
move.b D1,D2 /* Get reg # */
and.b #15,D1 /* reg 0-15 */
move.b D1,(A0) /* select reg */
asl.b #1,D2 /* test read/write bit */
bcc rdbt(PC) /* go read */
move.b D0,2(A0) /* write data to sound chip register */
rdbt: moveq #0,D0
move.b (A0),D0 /* read byte from sound chip register */
movem.l (A7)+,D1-D2/A0 /* restore registers */
move.w (A7)+,SR /* restore status */
rts
dtroff:
moveq #16,D2 /* set dtr bit */
bra setbt(PC) /* go set bit */
dtron:
moveq #-17,D2 /* clear dtr bit */
bra clrbt(PC) /* go clear bit */
setbt:
movem.l D0-D2,-(A7) /* Save registers */
move.w SR,-(A7) /* Save status */
ori.w #0x700,SR /* IPL 7, disable ints */
moveq #14,D1 /* port A */
move.l D2,-(A7) /* save bit # */
bsr giaccess(PC) /* Select port A */
move.l (A7)+,D2 /* bit # back */
or.b D2,D0 /* Set bits */
moveq #0x8E,D1 /* Write to port A */
bsr giaccess(PC) /* write new value */
move.w (A7)+,SR /* Restore status */
movem.l (A7)+,D0-D2 /* restore regs */
rts
clrbt:
movem.l D0-D2,-(A7) /* Save registers */
move.w SR,-(A7) /* Save status */
ori.w #0x700,SR /* IPL 7, disable ints */
moveq #14,D1 /* port A */
move.l D2,-(A7) /* save bit # */
bsr giaccess(PC) /* Select port A */
move.l (A7)+,D2 /* bit # back */
and.b D2,D0 /* Set bits */
moveq #0x8E,D1 /* Write to port A */
bsr giaccess(PC) /* write new value */
move.w (A7)+,SR /* Restore status */
movem.l (A7)+,D0-D2 /* restore regs */
rts
}
/* main - Determine if argument is "on" or "off". Assume "off" if no arg.
Process DTR accordingly. */
main(argc,argv)
int argc;
char *argv[];
{
if(argc > 1 && strcmp(argv[1],"on")==0){
Supexec(&dtron);
printf ("DTR has been turned on\n");
}
else{
Supexec(&dtroff);
printf ("DTR has been turned off\n");
}
}